package com.niuxiaofa.newlaw.adapter;

import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.niuxiaofa.newlaw.Bean.VideosBean;
import com.niuxiaofa.newlaw.R;
import com.niuxiaofa.newlaw.Tools.GlideUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


public class VideoAdapter extends RecyclerView.Adapter<VideoAdapter.ViewHolder> {
    public List<VideosBean.DataDTO> listEntities;
    Onclick onclick;

    List<String> list = new ArrayList<>();

    public VideoAdapter(List<VideosBean.DataDTO> newsList, Onclick onclick) {
        this.onclick = onclick;
        this.listEntities = newsList;
    }


    @Override
    public ViewHolder onCreateViewHolder( ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_video, viewGroup, false);
        ViewHolder viewHolder = new ViewHolder(view);

        list.add("https://img2.baidu.com/it/u=2950068170,3554303614&fm=26&fmt=auto&gp=0.jpg");
        list.add("https://pics2.baidu.com/feed/08f790529822720e125846174fb25640f01fabcc.jpeg?token=79c3bad38d7a29006bd0c21f0edce3bb");
        list.add("https://img2.baidu.com/it/u=1212541574,1961920017&fm=26&fmt=auto&gp=0.jpg");
        list.add("https://img2.baidu.com/it/u=2950068170,3554303614&fm=26&fmt=auto&gp=0.jpg");
        list.add("https://pics2.baidu.com/feed/08f790529822720e125846174fb25640f01fabcc.jpeg?token=79c3bad38d7a29006bd0c21f0edce3bb");
        list.add("https://img2.baidu.com/it/u=1212541574,1961920017&fm=26&fmt=auto&gp=0.jpg");

        list.add("https://img2.baidu.com/it/u=2950068170,3554303614&fm=26&fmt=auto&gp=0.jpg");
        list.add("https://pics2.baidu.com/feed/08f790529822720e125846174fb25640f01fabcc.jpeg?token=79c3bad38d7a29006bd0c21f0edce3bb");
        list.add("https://img2.baidu.com/it/u=1212541574,1961920017&fm=26&fmt=auto&gp=0.jpg");
        return viewHolder;
    }


    @Override
    public void onBindViewHolder( ViewHolder viewHolder, int i) {

         GlideUtils.loadRoundedImage(viewHolder.image.getContext(),list.get(i),viewHolder.image);

    }

    @Override
    public int getItemCount() {
        return listEntities.size();
    }

    public interface Onclick {

        void onclick(int c);

    }

    static class ViewHolder extends RecyclerView.ViewHolder {



        @BindView(R.id.image)
        ImageView image;



        public ViewHolder( View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
